package com.homedo.microservice.open.service.gateway.manager.web.gateway.bean.po.enhanced;

import com.homedo.common.dao.bean.po.enhanced.base.BaseEnhanced;
import com.homedo.microservice.open.service.gateway.manager.web.gateway.bean.enums.forroute.StatusEnum4Route;
import com.homedo.microservice.open.service.gateway.manager.web.gateway.bean.po.RouteVersion;
import org.springframework.beans.BeanUtils;

import java.util.Date;

/**
 * @author 作者 jgshun
 * @date 创建时间 2018年09月19日 17时16分40秒
 */
public class RouteVersionEnhanced extends BaseEnhanced {
    public RouteVersionEnhanced(RouteVersion routeVersion) {

        BeanUtils.copyProperties(routeVersion, this);

        //自动生成 细微误差自己调整

        if (routeVersion.getRouteId() != null) {
            RouteEnhanced routeEnhanced = new RouteEnhanced();
            routeEnhanced.setId(routeVersion.getRouteId());
            this.routeEnhanced = routeEnhanced;
        }
        if (routeVersion.getServiceId() != null) {
            RouteServiceEnhanced routeServiceEnhanced = new RouteServiceEnhanced();
            routeServiceEnhanced.setId(routeVersion.getServiceId());
            this.routeServiceEnhanced = routeServiceEnhanced;
        }
        if (routeVersion.getStatus() != null) {
            this.status = StatusEnum4Route
                    .getStatusEnumByCode(routeVersion.getStatus().shortValue());
        }
    }

    public RouteVersionEnhanced() {
    }

    private Integer id;
    private String version;
    private RouteEnhanced routeEnhanced;
    private RouteServiceEnhanced routeServiceEnhanced;
    private Date createTime;
    private Date updateTime;
    private String comment;
    private StatusEnum4Route status;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getVersion() {
        return version;
    }

    public void setVersion(String version) {
        this.version = version;
    }

    public RouteEnhanced getRouteEnhanced() {
        return routeEnhanced;
    }

    public void setRouteEnhanced(RouteEnhanced routeEnhanced) {
        this.routeEnhanced = routeEnhanced;
    }

    public RouteServiceEnhanced getRouteServiceEnhanced() {
        return routeServiceEnhanced;
    }

    public void setRouteServiceEnhanced(RouteServiceEnhanced routeServiceEnhanced) {
        this.routeServiceEnhanced = routeServiceEnhanced;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public String getComment() {
        return comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }

    public StatusEnum4Route getStatus() {
        return status;
    }

    public void setStatus(StatusEnum4Route status) {
        this.status = status;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        RouteVersionEnhanced that = (RouteVersionEnhanced) o;

        if (id != null ? !id.equals(that.id) : that.id != null) return false;
        if (version != null ? !version.equals(that.version) : that.version != null) return false;
        if (routeEnhanced != null ? !routeEnhanced.equals(that.routeEnhanced) : that.routeEnhanced != null)
            return false;
        if (routeServiceEnhanced != null ? !routeServiceEnhanced.equals(that.routeServiceEnhanced) : that.routeServiceEnhanced != null)
            return false;
        if (createTime != null ? !createTime.equals(that.createTime) : that.createTime != null) return false;
        if (updateTime != null ? !updateTime.equals(that.updateTime) : that.updateTime != null) return false;
        if (comment != null ? !comment.equals(that.comment) : that.comment != null) return false;
        return status == that.status;
    }

    @Override
    public int hashCode() {
        int result = id != null ? id.hashCode() : 0;
        result = 31 * result + (version != null ? version.hashCode() : 0);
        result = 31 * result + (routeEnhanced != null ? routeEnhanced.hashCode() : 0);
        result = 31 * result + (routeServiceEnhanced != null ? routeServiceEnhanced.hashCode() : 0);
        result = 31 * result + (createTime != null ? createTime.hashCode() : 0);
        result = 31 * result + (updateTime != null ? updateTime.hashCode() : 0);
        result = 31 * result + (comment != null ? comment.hashCode() : 0);
        result = 31 * result + (status != null ? status.hashCode() : 0);
        return result;
    }
}